import Vue from 'vue'
import Router from 'vue-router'
import login from '@/components/login'
import body from '@/components/body'
import error from '@/components/404.vue'
import childView from '@/components/appMain.vue'
import HelloWorld from '@/components/HelloWorld'

Vue.use(Router)
/**
 * routes==默认路由节点
 */
export const routes = [
  {
    path: '/login',
    name: '登录',
    component: login,
    hidden: true
  },
  {
    path: '/',
    name: '工作台',
    meta: {
      role: 'work'
    },
    component: body,
    iconCls: 'icon-iconfontdesktop',
    leaf: true, // 只有一个节点
    redirect: '/work',
    children: [{
      path: '/work',
      component: HelloWorld
    }]
  }
]

export const ansycRoutes = [
  {
    path: '/',
    name: '用户管理', // 用户管理
    component: body,
    iconCls: 'icon-user',
    meta: {
      isLink: true
    },
    children: [
      {
        path: '/adminGlobal',
        name: '管理员(全站)', // 管理员(全站)
        component: childView,
        isParent: true,
        redirect: '/adminGlobal/list',
        children: [{
          path: '/adminGlobal/list', // 管理员列表(全站)
          name: '管理员(全站)列表',
          component: resolve => { require(['@/views/user/admin/global/list.vue'], resolve) }
        }, {
          path: '/adminGlobal/edit', // 管理员编辑页(全站)
          name: '管理员(全站)编辑',
          component: resolve => { require(['@/views/user/admin/global/edit.vue'], resolve) },
          hidden: true
        }, {
          path: '/adminGlobal/add', // 管理员添加页(全站)
          name: '管理员(全站)添加',
          component: resolve => { require(['@/views/user/admin/global/add.vue'], resolve) },
          hidden: true
        }]
      }
    ]
  },
  {
    path: '*',
    name: '404',
    component: error,
    meta: {
      role: 'index'
    },
    hidden: true
  }
]
